package com.example.tacocloudemail;

import org.springframework.integration.handler.GenericHandler;
import org.springframework.messaging.MessageHeaders;
import org.springframework.web.client.RestTemplate;

import java.util.Map;

public class OrderSubmitMessageHandler implements GenericHandler<Order> {

    private RestTemplate rest;
    private ApiProperties properties;

    public OrderSubmitMessageHandler(RestTemplate rest, ApiProperties properties) {
        this.rest = rest;
        this.properties = properties;
    }

    @Override
    public Object handle(Order order, MessageHeaders messageHeaders) {
        rest.postForObject(properties.getUrl(), order, String.class);
        return null;
    }
}
